﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using UI.Lib;
using Controls;
using Components;

namespace UI.ShopManagement
{
    public partial class FrmBas1a20Edit : UI.ParentForm.BaseEdit
    {
        public FrmBas1a20Edit(string action, string text, string key)
            : base(action)
        {
            InitializeComponent();

            this.Text = text;
            this.key = key;
            //回写的方法
            this.SaveCallFuntion = "Bas1a20Manager$SaveData"; //保存的方法
            if ("A" == this.Action)
            {
                IsAfterSaveCloseWin = false;
            }
            else
            {
                LoadData();
            }

            this.Size = base.MaxWindow;
        }

        protected override void PageInit()
        {
        }

        public override bool BeforePopWin(string name, ref string where, ref string[] others)
        {
            if ("sellercode" == name)
            {
                where = string.Format("status=1 {0}", Context.GetAppKeyWhere("usercode", true));
            }

            return true;
        }

        protected override void AfterSummaryCreateControl(string colName, Control c, Controls.Args.SummaryArgs e)
        {
            if ("setting" == colName) //验证门店代码是否存在
            {
                var btnSetting = c as Button;
                btnSetting.Click += new EventHandler(btnSetting_Click);
            }
        }

        void btnSetting_Click(object sender, EventArgs e)
        {
            var frm = new FrmBas1a22Edit("U", "门店参数设置", this.key);
            frm.ShowDialog();
        }

        //加载修改数据
        private void LoadData()
        {
            base.LoadEditData(null, string.Format(" a.listid ='{0}' ", this.key));
        }
    }
}